package PerDNSServer2;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 * @Author: 0162977
 * @Date: 2020/12/3 16:06
 */
public class PerMainThread {
    public static void main(String[] args) throws IOException {

        Thread manage_thread = new Thread(new ManageThread());
        manage_thread.start();

        DatagramSocket socket = new DatagramSocket(ShareSpaceAndFun.myPort);
        DatagramPacket packet = null;
        byte[] data = null;
        System.out.println("***权限服务器2启动***");
        while(true){
            data = new byte[1024];//创建字节数组，指定接收的数据包的大小
            packet = new DatagramPacket(data, data.length);
            socket.receive(packet);//此方法在接收到数据报之前会一直阻塞
            Thread thread = new Thread(new ListenThread(socket, packet));
            thread.start();
        }
    }
}